package packets.c2spackets;

import network.MCConnection;
import exceptions.UnrecoverableException;
import packets.PacketHandler;
import packets.s2cpackets.S0x02;
import world.WorldState;

public class P0x02 extends PacketHandler {

	public P0x02(WorldState state) {
		super(state);
	}

	@Override
	public void handle(MCConnection conn) throws UnrecoverableException {
		/**
		 * Receiving 1 string from the server, holding connection info.
		 * It is formatted in the following way:
		 *   USERNAME;HOSTNAME;PORTNUMBER
		 */
		String connectioninfo = conn.r.readString();
		
		String username = connectioninfo.split(";")[0];
		System.out.println("User tries to connect: "+username);
		
		//return "-", meaning that this server will not use authentication.
		conn.send(new S0x02());
	}

}
